<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page import="java.util.Date"%>
<!-- 引入EasyUI的样式文件-->
<link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/easyui.css"/>
<!-- 引入EasyUI的图标样式文件-->
<link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/easyui_animation.css"/>
<link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/easyui_plus.css"/>
<link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/insdep_theme_default.css"/>
<link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/icon.css"/>
<link rel="stylesheet" href="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/plugins/font-awesome-4.7.0/css/font-awesome.min.css"/>

<!-- 引入JQuery -->
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/jquery.min.js"></script>
<!-- 引入EasyUI -->
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/jquery.easyui.min.js"></script>
<!-- 引入EasyUI的中文国际化js，让EasyUI支持中文 -->
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/jquery.insdep-extend.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jquery-easyui-1.5.2/themes/insdep/insdep-extend.min.js"></script>

<%--引入自定义的公用js、组件js、校验js--%>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/js/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/js/validate.js"></script>

<%--定义错误弹框--%>
<div id="winErrorDetail" class="easyui-dialog" data-options="closed:true" style=" width:500px;height:200px"></div>

<script type="text/javascript">
    var rootPath = "<%=request.getContextPath()%>"
    $.extend($.fn.datagrid.methods, {
        fixRownumber : function (jq) {
            return jq.each(function () {
                var panel = $(this).datagrid("getPanel");
                var clone = $(".datagrid-cell-rownumber", panel).last().clone();
                clone.css({
                    "position" : "absolute",
                    left : -1000
                }).appendTo("body");
                var width = clone.width("auto").width();
                if (width > 25) {
                    //多加5个像素,保持一点边距
                    $(".datagrid-header-rownumber,.datagrid-cell-rownumber", panel).width(width + 5);
                    $(this).datagrid("resize");
                    //一些清理工作
                    clone.remove();
                    clone = null;
                } else {
                    //还原成默认状态
                    $(".datagrid-header-rownumber,.datagrid-cell-rownumber", panel).removeAttr("style");
                }
            });
        }
    });

    /**
     * 扩展两个方法
     */
    $.extend($.fn.datagrid.methods, {
        /**
         * 开打提示功能
         * @param {} jq
         * @param {} params 提示消息框的样式
         * @return {}
         */
        doCellTip: function (jq, params) {
            function showTip(data, td, e) {
                if ($(td).text() == "")
                    return;
                data.tooltip.text($(td).text()).css({
                    top: (e.pageY + 10) + 'px',
                    left: (e.pageX + 20) + 'px',
                    'z-index': $.fn.window.defaults.zIndex,
                    display: 'block'
                });
            };
            return jq.each(function () {
                var grid = $(this);
                var options = $(this).data('datagrid');
                if (!options.tooltip) {
                    var panel = grid.datagrid('getPanel').panel('panel');
                    var defaultCls = {
                        'border': '1px solid #333',
                        'padding': '1px',
                        'color': '#333',
                        'background': '#f7f5d1',
                        'position': 'absolute',
                        'max-width': '200px',
                        'border-radius': '4px',
                        '-moz-border-radius': '4px',
                        '-webkit-border-radius': '4px',
                        'display': 'none'
                    }
                    var tooltip = $("<div id='celltip'></div>").appendTo('body');
                    tooltip.css($.extend({}, defaultCls, params.cls));
                    options.tooltip = tooltip;
                    panel.find('.datagrid-body').each(function () {
                        var delegateEle = $(this).find('> div.datagrid-body-inner').length
                            ? $(this).find('> div.datagrid-body-inner')[0]
                            : this;
                        $(delegateEle).undelegate('td', 'mouseover').undelegate(
                            'td', 'mouseout').undelegate('td', 'mousemove')
                            .delegate('td', {
                                'mouseover': function (e) {
                                    if (params.delay) {
                                        if (options.tipDelayTime)
                                            clearTimeout(options.tipDelayTime);
                                        var that = this;
                                        options.tipDelayTime = setTimeout(
                                            function () {
                                                showTip(options, that, e);
                                            }, params.delay);
                                    } else {
                                        showTip(options, this, e);
                                    }

                                },
                                'mouseout': function (e) {
                                    if (options.tipDelayTime)
                                        clearTimeout(options.tipDelayTime);
                                    options.tooltip.css({
                                        'display': 'none'
                                    });
                                },
                                'mousemove': function (e) {
                                    var that = this;
                                    if (options.tipDelayTime) {
                                        clearTimeout(options.tipDelayTime);
                                        options.tipDelayTime = setTimeout(
                                            function () {
                                                showTip(options, that, e);
                                            }, params.delay);
                                    } else {
                                        showTip(options, that, e);
                                    }
                                }
                            });
                    });

                }

            });
        },
        /**
         * 关闭消息提示功能
         * @param {} jq
         * @return {}
         */
        cancelCellTip: function (jq) {
            return jq.each(function () {
                var data = $(this).data('datagrid');
                if (data.tooltip) {
                    data.tooltip.remove();
                    data.tooltip = null;
                    var panel = $(this).datagrid('getPanel').panel('panel');
                    panel.find('.datagrid-body').undelegate('td',
                        'mouseover').undelegate('td', 'mouseout')
                        .undelegate('td', 'mousemove')
                }
                if (data.tipDelayTime) {
                    clearTimeout(data.tipDelayTime);
                    data.tipDelayTime = null;
                }
            });
        }
    });

    function showInformation(name) {
        $('#' + name).datagrid({
            onLoadSuccess: function (data) {
                $('#' + name).datagrid('doCellTip', {
                    onlyShowInterrupt: false,     //是否只有在文字被截断时才显示tip，默认值为false
                    position: 'bottom',   //tip的位置，可以为top,botom,right,left
                    cls: { 'background-color': '#D1EEEE' },  //tip的样式
                    delay: 100   //tip 响应时间
                });
            }
        });
        $('.datagrid-header div').css('textAlign', 'center');
    }

    function showErrorDetail(){
        $("#fieErrorDetail").toggle();
    }

</script>
<style type="text/css">
    .search-form{
        float:left;
        margin-bottom: 5px;
    }
    .search-form div{
        float: left;
        min-width: 250px;
    }
    .search-form div .textbox{
        min-width: 160px !important;
    }
    .toolBar{
        display:inline-block;
        width: 100%;
        padding-top: 5px;
        border-top: 1px solid #ccc;
    }
    .easyui-dialog .datagrid-toolbar{
        border-width:0
    }

    div .textbox-label{
        min-width: 80px;
    }
    .easyui-dialog .search-form div{
        margin-top: 5px;
    }
    .textarea .textbox{
        min-height: 100px;
    }
    .textarea .textbox textarea{
        min-height: 92px !important;
    }
    .search-btn{
        margin-left: 5px;
    }
    .window .window-header .panel-with-icon{
        padding-left: 15px;
    }
    .icon-line{
        display: inline-block;
        width: 30px;
        height: 30px;
    }
</style>